2024-08-21

Please click on the right side of the slide to view the next one.

R Code

The following code uses the ChickWeight database, which contains the weight data in gram of 48 individual chicks during their growth, as a function of time and diet. There are 4 different diets, and the timeframe goes from 0 to 21 days maximum.

library(plotly)
library(dplyr)

plot1 <- ggplot(ChickWeight, aes(x = Time, y = weight, 
                                 color = factor(Chick))) +
  geom_line() +
      geom_point(size = 0.5) +  
  facet_wrap(~Diet) +
  labs(title = "Chicks growth as a function of their diet and time", 
       x = "Time [days]", 
       y = "Weight [g]") +
      theme(legend.position = "none")

Chick growth trajectories

The plot below shows individual chick weight growth grouped by diet, with each subplot representing a different diet.

ggplotly(plot1)